package crudfx.field;
import crudfx.interop.*;
import crudfx.data.*;
import javax.swing.*;
import java.awt.event.*;
/**
 * @profile desktop
 * @author Sergey Surikov
 */
public class BooleanField extends UIComponent{
    protected var jCheckBox:JCheckBox;
    public var text:String on replace {jCheckBox.setText(text);};
    public var value:Boolean on replace {jCheckBox.setSelected(value);};
    init{
        jCheckBox=new JCheckBox();
        jCheckBox.setSelected(value);
        jCheckBox.setText(text);
        jCheckBox.setOpaque(false);
        jCheckBox.addActionListener(ActionListener{
                override function actionPerformed(e:ActionEvent){
                            value=jCheckBox.isSelected();
                        }
                    }
            );
        }
    override public function getJComponent():JComponent{
        return jCheckBox;
        }
    override public function highlight(s:String):Boolean{
        return false;
        }
    override public function gather():DataTree{
        var me:DataTree=DataTree{ name:"BooleanField" };
        me.node("value").asBoolean(false).value=value;
        return me;
        }
    }
